﻿using System;
using System.Collections.Generic;
using System.Collections;
using OrgChart.Entity;
using App.Data;

namespace OrgChart.Logic
{
    public class DictionaryLogic
    {
        public List<DictionaryEntity> GetDictionaryList()
        {
            List<DictionaryEntity> lists = new List<DictionaryEntity>();
            lists = DataAccess.Instance("BusinessDB").GetList<DictionaryEntity>("DictionaryLogic_GetDictionaryList", null);
          
            return lists;
        }

        public List<DictionaryEntity> GetTopDictionaryList(string dictionary_type)
        {
            List<DictionaryEntity> lists = GetDictionaryList();
            return lists.FindAll(delegate(DictionaryEntity ety) {
                if (string.IsNullOrEmpty(ety.PARENT_DICTIONARY_ID) && ety.DICTIONARY_TYPE.ToUpper().Trim()==dictionary_type.ToUpper().Trim())
                {
                    return true;
                }
                return false;
            });
        }

        public List<DictionaryEntity> GetChildDictionaryList(string parent_dictionary_id)
        {
            List<DictionaryEntity> lists = GetDictionaryList();
            return lists.FindAll(delegate(DictionaryEntity ety)
            {
                if (!string.IsNullOrEmpty(ety.PARENT_DICTIONARY_ID) &&
                    ety.PARENT_DICTIONARY_ID.ToUpper().Trim() == parent_dictionary_id.ToUpper().Trim())
                {
                    return true;
                }
                return false;
            });
        }

        public void InsertSecurity(string userGroup, string dictionaryID)
        {

        }
    }
}
